<template>
  <div>
    <button @click="hq">获取课程的门数</button>
    <br />
    {{ count }}<br />
    {{ total }}<br />
    {{ tcount }}
    <hr />
    全名:{{ fullName }}<br />
    全名:{{ fname }}<br />
  </div>
</template>

<script>
export default {
  data() {
    return {
      course: ["wpf", "vue"],
      count: 0,
      tcount: 0,
      firstName:"刘",
      lastName:"大大",
      fname:""
    };
  },
  methods: {
    hq() {
      this.count = this.course.length + "门";
    },
  },
  computed: {
    total() {
      return this.course.length + "门";
    },
    fullName(){
        return this.firstName+this.lastName; 
    }
  },
  watch: {
    course: {
      immediate: true,
      handler: function (newValue) {
        this.tcount = newValue.length + "门";
      },
    },
    firstName: {
            immediate: true,
            deep: true,
            handler(newValue) {
                this.fname=newValue+this.lastName;
            }
        },
         lastName: {
            immediate: true,
            deep: true,
            handler(newValue) {
                this.fname=this.firstName+newValue;
            }
        }
  }
   

};
</script>

<style scoped>
</style>